<template>
    <div id="app">
        <div id="cover"></div>
        <!-- <div id="loading">
            <loading></loading>
        </div> -->
        <Header></Header>
        <h1>{{fullName}} --- {{counter}}  <span> {{textA}} </span> </h1>
        <router-link to="/app" >app</router-link>
        <router-link to="/login" >login</router-link>
        <router-link to="/app/test" >test</router-link> 
        
       

        <transition name="fade" mode='out-in' appear type="transition" >
            <router-view />
        </transition>
        <!-- <notification content="test notify"></notification> -->
        <!-- <router-view name="a" /> -->
        <button @click="notify">notify1</button>
        <Footer></Footer>
    </div>
</template>

<script>
import Header from './todo/header.vue'
import Footer from './todo/footer.jsx'
import {mapState, mapGetters, mapActions, mapMutations} from 'vuex'
import Loading from './components/loading/loading.vue'
export default {
    metaInfo: {
        title: 'Jokcy Todo App'
    },
   components:{
       Header,
       Footer,
       Loading
   },
   mounted(){
    //    this.$notify({
    //        content: 'test $notify'
    //    })
        // console.log(this.$route)
        // console.log(this.$store)
        let i = 1
        // setInterval(()=>{
        //     this.updateCount(i++)
        // }, 1000)
        this['a/updateText'](123)
        this['a/add']()
        this.testAction()
        //    this.$store.dispatch("updateCountAsync",{
        //        num: 5,
        //        time: 2000
        //    })
        // this.updateCountAsync({
        //     num: 9,
        //     time: 2000
        // })

   },
   computed:{
        ...mapState({
            counter: (state) => state.count,
            textA: state => state.a.text
        }),
        ...mapGetters({
            fullName: "fullName",
            // textPlus: "a/textPlus"
        })
        //    textA(){
        //        return this.$store.state.a.text
        //    },
        //    fullName(){
        //        return this.$store.getters.fullName
        //    }
   },
   methods: {
       ...mapActions(['updateCountAsync', 'a/add', 'testAction']),
       ...mapMutations(['updateCount', 'a/updateText']),
       notify(){
           this.$notify({
               content: 'test $notify'
           })
       }
   }
}
/**
 * env不支持解析...运算符
 * 需要安装babel-preset-stage-1
 *  */ 
</script>

<style lang="stylus" scoped>
#app{
    position absolute
    left 0
    right 0
    top 0
    bottom 0
}
#cover{
    position absolute
    left 0
    right 0
    top 0
    bottom 0
    background-color #fff
    opacity .5
    z-index -1
    }
#loading{
  position fixed
  top 0
  right 0
  bottom 0
  left 0
  background-color rgba(255,255,255,.3)
  z-index 99
  display flex
  align-items center
  justify-content center
}
</style>
